package com.xinhe.web.controller;

import com.xinhe.web.annotation.WebUsed;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.GoodsType;
import com.xinhe.web.response.GoodsTypeView;
import com.xinhe.web.service.GoodsTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "商品分类列表", tags = {"商品分类列表"})
@RestController
@RequestMapping(value = {"/goodsType"}, produces = {"application/json;charset=UTF-8"})

public class GoodsTypeController {
    @Autowired
    private GoodsTypeService goodsTypeService;

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "分页查询商品分类")
    @RequestMapping({"/pageGoodsType"})
    public Result<List<GoodsTypeView>> pageGoodsType() {
        return this.goodsTypeService.pageGoodsType();
    }

    @WebUsed
    @ApiOperation(httpMethod = "POST", value = "保存商品分类")
    @RequestMapping({"/saveGoodsType"})
    public Result saveGoodsType(Long id,String name,String iconPath,Integer seq,String remark) {
        return this.goodsTypeService.saveModel(id,name,iconPath,seq,remark);
    }

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "删除商品分类")
    @ApiImplicitParam(name = "goodsTypeId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteGoodsType"})
    public Result deleteGoodsType(Long goodsTypeId) {
        return this.goodsTypeService.delete(goodsTypeId);
    }

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "商品分类详情")
    @ApiImplicitParam(name = "goodsTypeId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailGoodsType"})
    public Result<GoodsType> detailGoodsType(Long goodsTypeId) {
        return this.goodsTypeService.findById(goodsTypeId);
    }
}
